/**
 * @Title: integrityMedical_service.js
 * @Description: 结算首页service
 * Copyright: Copyright (c) 2014 
 * Company:中国平安
 *
 * @Project HIMS-FWA
 * @author ex-xieyuwen001
 * @date 2014年10月29日 下午14:36:25
 * @version V1.0
 */
;
(function(){
	'use strict';
	
	
	
	var app = angular.module('fwa.services');
	app.service('IntegrityMedicalService',['$http','BaseURL', function($http, baseUrl){
		var debug = false,
		serv = this,
		debugUrls = {
				getIntegrityMedical:baseUrl + 'mock/achievements/integrity/integrityMedical.json',
				getIntegrityMedicalDesc:baseUrl + 'mock/achievements/integrity/integrityMedicalDesc.json',
				getIntegrityMedicalMark:baseUrl + 'mock/achievements/integrity/integrityMedicalMark.json'
			},
			urls = {
				getIntegrityMedical:baseUrl + 'integrityMedical/integrityMedical.do',
				getIntegrityMedicalDesc:baseUrl + 'integrityMedical/integrityMedicalDesc.do',
				getIntegrityMedicalMark:baseUrl + 'integrityMedical/integrityMedicalMark.do',
				getIntegrityDoctor:baseUrl + 'integrityMedical/integrityDoctors.do',
				getIntegrityOrg:baseUrl + 'integrityMedical/integrityOrgs.do',
				getIntegrityExport:baseUrl + 'integrityMedical/integrityMedicalReport.do',
				getIntegrityMedicalTotal:baseUrl + 'integrityMedical/integrityMedicalTotal.do',
				saveIntegrityPoints:baseUrl + 'integrityMedical/saveIntegrityPoints.do',
				getInsuredMedicalDetail:baseUrl + 'integrityDetail/integrityDetailList.do',
				findIntegrityInsuranceDesc:baseUrl + 'integrityMedicalDesc/findIntegrityInsuranceDesc.do',
				doctorIllegalDesc:baseUrl + 'doctorIntegrity/doctorIllegalDesc.do',
				getInsuredMedicalListAdd:baseUrl + 'integrityMedicalDesc/insuredMedicalListAdd.do',
//				scratchIntegrityPoints:baseUrl + 'integrityMedical/saveIntegrityPoints.do',//医务人员暂存
				getInsuredMedicalDetailList:baseUrl+'integrityDetail/integrityDetailList.do',
				getMedicalApproveList:baseUrl+'integrityApprove/integrityApproveList.do',
				getMedicalApproveDetail:baseUrl+'integrityApprove/integrityApproveDetail.do'
			};
		serv.systemIntegritys = [];
		serv.ownerIntegritys = [];
		serv.systemIntegrityMarks = [];
		serv.ownerIntegrityMarks = [];
		serv.startDate = null;
		serv.endDate = null;
		serv.doctorCode = null;
		serv.status = null;
		serv.saveStatus = null;
		serv.taskNo = null;
		serv.orgCode=null;
		serv.insuranceName=null;
		serv.updatedBy = null;//最近操作人（审批查看详情用）
		serv.batchTaskNos = null;
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		};
		//查询医务人员列表
		serv.getInsuredMedicalDetail=function(params){
			return $http({
				url:getUrl('getInsuredMedicalDetailList'),
				method:'GET',
				params:params 
			});
		}
		serv.getIntegrityMedical = function(params) {
			return $http({
				url:getUrl('getIntegrityMedical'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityMedicalDesc = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalDesc'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityMedicalMark = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalMark'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityExport = function(params) {
			return $http({
				url:getUrl('getIntegrityExport'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityMedicalTotal = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalTotal'),
				method:'GET',
				params:params
			});
		}
		//医务人员登记查询
		serv.getInsuredMedicalListAdd = function(params) {
			return $http({
				url:getUrl('getInsuredMedicalListAdd'),
				method:'GET',
				params:params
			});
		}
		//医生列表
		serv.getIntegrityDoctor = function(params) {
			return $http({
				url:getUrl('getIntegrityDoctor'),
				method:'GET',
				params:params
			});
		}
		//机构列表
		serv.getIntegrityOrg = function(params) {
			return $http({
				url:getUrl('getIntegrityOrg'),
				method:'GET',
				params:params
			});
		}
		//记分录入查询
		serv.getInsuredMedicalDetail = function(params) {
			return $http({
				url:getUrl('getInsuredMedicalDetail'),
				method:'GET',
				params:params
			});
		}
		//记分录入机构明细查询
		serv.findIntegrityInsuranceDesc = function(params) {
			return $http({
				url:getUrl('findIntegrityInsuranceDesc'),
				method:'GET',
				params:params
			});
		}
		//记分录入明细查询
		serv.doctorIllegalDesc = function(params) {
			return $http({
				url:getUrl('doctorIllegalDesc'),
				method:'GET',
				params:params
			});
		}
		/**医疗机构**/
        serv.initMedicalOrgInfoList = function(){
			if(!serv.medicalOrgInfoList){
				$http({
			    	 method: "get",
			    	 url:baseUrl+'community/getNewMedicalOrgInfoList.do'
				}).success(function(response, status, headers, config){
					serv.medicalOrgInfoList = response.medicalOrgList;
				});
			}
		}
        /**预警次数**/
		serv.queryWarnInfoCount = function(params) {
			return $http({
				 url:baseUrl+'doctorIntegrity/warnInfoCount.do',
				method:'GET',
				params:params
			});
		}
		
        /**医务人员审核列表信息**/
		serv.getIntegrityAuditInfo = function(params) {
			return $http({
				 url:baseUrl+'doctorIntegrity/getIntegrityAuditInfo.do',
				method:'GET',
				params:params
			});
		}
		
        /**医务人员审核详细信息**/
		serv.getIntegrityAuditDetail = function(params) {
			return $http({
				 url:baseUrl+'doctorIntegrity/getIntegrityAuditDetail.do',
				method:'GET',
				params:params
			});
		}
		
				/**医护人员审批列表信息*/
		serv.getMedicalApproveList=function(params){
			return $http({
				url:getUrl('getMedicalApproveList'),
				method:'GET',
				params:params 
			});
		}
		/**医护人员审批详情信息*/
		serv.getMedicalApproveDetail=function(params){
			return $http({
				url:getUrl('getMedicalApproveDetail'),
				method:'GET',
				params:params 
			});
		}
        
		//人工录入扣分
	     serv.saveIntegrityPoints = function (params){
	    	 return $http.post(getUrl('saveIntegrityPoints'),params);
	     }
		/**获得开始时间*/
		serv.getStartDate= function(){
			var date = new Date();
			date.setMonth(date.getMonth());
			var year1 = date.getFullYear()-1;
			var month1 = date.getMonth();
			if(month1 < 12){
				month1 += 1;
			}else{
				year1 += 1;
				month1 = 1;
			}
			var d = date.getDate();
			month1 = month1 < 10 ? ("0" + month1) : month1;
			var startDate = year1 + "-" + month1 + '-' +d;
			return startDate;
		}
		/**获得结束时间*/
		serv.getEndDate= function(){
			var date = new Date();
			date.setMonth(date.getMonth());
			var year1 = date.getFullYear();
			var month1 = date.getMonth()+1;
			var d = date.getDate();
			month1 = month1 < 10 ? ("0" + month1) : month1;
			var startDate = year1 + "-" + month1 + '-' +d;
			return startDate;
		}
		
	}]);
	
})();